<?php
namespace app\home\model;
use think\Db;
class Crawler
{
    public static function getlist(){
        $res=vendor('phpquery.Query');
        $qy = new \Query();
        header("content-Type: text/html; charset=Utf-8");
        $pattern =array('picture'=>array('.chapter-list li a','text'),'url'=>array('.chapter-list li a','href'));
        $url="http://book.zongheng.com/showchapter/672340.html";
        $aaa=$qy -> QueryList($url, $pattern, '', '', 'utf-8');
        $rs = $qy->jsonArr;
        return $rs;
    }
    public static function articledetail(){
        $res=vendor('phpquery.Query');
        $qy = new \Query();
        header("content-Type: text/html; charset=Utf-8");
        $list=Db::table('cms_article')->where(" novel_name = '剑来' ")->select();
        $pattern =array('content'=>array('.content','text'));
        foreach($list as $key =>$val){
            $url=$val['original_url'];
            $aaa=$qy -> QueryList($url, $pattern, '', '', 'utf-8');
            $rs = $qy->jsonArr;
            // p($rs);
            Db::table('cms_article')->where(['id'=>$val['id']])->update(['message'=>$rs[0]['content']]);
        }


        // return $rs;
    }
}